#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 20

char *reverse(char *str);
int main(int argc, char **argv)
{
    char *str = (char *)malloc(MAX);
    if (str == NULL)
    {
        return -1;
    }
    printf("input a string :");
    fgets(str,MAX+1,stdin);
    fputs(reverse(str),stdout);

    free(str);
    str = NULL;
    return 0;
}

char *reverse(char *str)
{
    int len = strlen(str);
    int i = 0;
    int n = len/2;
    char tmp;

    for (i=0;i<n;i++)
    {
        tmp = str[i];
        str[i] = str[len-i-1];
        str[len-i-1] = tmp;
    }
    
    return str;
}
